<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <meta http-equiv="CONTENT-TYPE" content="text/html; charset=UTF-8">
  <title>The MRQL System Functions</title>
  <meta name="GENERATOR" content="OpenOffice.org 3.2  (Linux)">
  <meta name="CREATED" content="0;0">
  <meta name="CHANGEDBY" content="fegaras ">
  <meta name="CHANGED" content="20111021;14130400">
  <style type="text/css">
	<!--
		PRE { background: #eeeeee; font-size:90%; font-family: "Monaco", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Lucida Console", monospace }
		H2.ctl { font-family: "Lohit Hindi" }
		H3.ctl { font-family: "Lohit Hindi" }
		TT { font-size:85%; font-family: "Monaco", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Lucida Console", monospace; background: #eeeeee }
	-->
	</style>
</head>
<body dir="LTR" lang="en-US">
<h1 align="CENTER">The MRQL System Functions</h1>
<hr>
Infix arithmetic operators: +, -, *, /, %, &lt;, &lt;=, &gt;, &gt;=
<br>
Constants: PI (for &pi;)
<p>
In the following system functions, &alpha; stands for any type, numeric stands for any numerical value, and all functions on bags can be applied to other collections types too.
<p>
<table border="0" width="100%">
<tbody>
<tr valign="top"><td><h3>Name</h3></td><td><h3>Type</h3></td><td><h3>Description</h3></td></tr>
<tr><td>=</td><td>(&alpha;,&alpha;) &rarr; boolean</td><td>equality (infix)</td></tr>
<tr><td>&lt;&gt;</td><td>(&alpha;,&alpha;) &rarr; boolean</td><td>not equal (infix)</td></tr>
<tr><td>+</td><td>(string,string) &rarr; string</td><td>string concatenation (infix)</td></tr>
<tr><td>+</td><td>(bag(&alpha;),bag(&alpha;)) &rarr; bag(&alpha;)</td><td>bag union (infix)</td></tr>
<tr><td>..</td><td>(long,long) &rarr; bag(long)</td><td>a list of long integers from min to max (infix)</td></tr>
<tr><td>min</td><td>(numeric,numeric) &rarr; numeric</td><td>the minimum numerical value</td></tr>
<tr><td>max</td><td>(numeric,numeric) &rarr; numeric</td><td>the maximum numerical value</td></tr>

<tr><td>abs</td><td>numeric &rarr; numeric</td><td>the absolute value</td></tr>
<tr><td>log</td><td>numeric &rarr; float/double</td><td>natural logarithm</td></tr>
<tr><td>exp</td><td>numeric &rarr; float/double</td><td>e raised to the power of the value</td></tr>
<tr><td>pow</td><td>(double,double) &rarr; double</td><td>raise to the power</td></tr>
<tr><td>round</td><td>float &rarr; int</td><td>rounding a float into an integer</td></tr>
<tr><td>round</td><td>double &rarr; long</td><td>rounding a double into a long</td></tr>
<tr><td>&phi;</td><td>double &rarr; double</td><td>&phi; is a math function from Java Math package (sin, cos, tan, asin, acos, atan, sqrt, ceil, floor, rint)</td></tr>

<tr><td>toShort</td><td>string &rarr; short</td><td>convert a string to a short</td></tr>
<tr><td>toInt</td><td>string &rarr; int</td><td>convert a string to an int</td></tr>
<tr><td>toLong</td><td>string &rarr; long</td><td>convert a string to a long</td></tr>
<tr><td>toFloat</td><td>string &rarr; float</td><td>convert a string to a float</td></tr>
<tr><td>toDouble</td><td>string &rarr; double</td><td>convert a string to a double</td></tr>
<tr><td>toBool</td><td>string &rarr; boolean</td><td>convert a string to a boolean</td></tr>
<tr><td>string</td><td>&alpha; &rarr; string</td><td>convert any MRQL type to a string</td></tr>
<tr><td>contains</td><td>(string,string) &rarr; boolean</td><td>true if the first string contains the second string</td></tr>
<tr><td>length</td><td>string &rarr; int</td><td>string size</td></tr>
<tr><td>substring</td><td>(string,int,int) &rarr; string</td><td>substring from beginIndex to endIndex</td></tr>

<tr><td>count</td><td>bag(&alpha;) &rarr; long</td><td>the number of elements in the bag</td></tr>
<tr><td>sum</td><td>bag(numeric) &rarr; numeric</td><td>sum of all values</td></tr>
<tr><td>max</td><td>bag(numeric) &rarr; numeric</td><td>maximum of all values</td></tr>
<tr><td>min</td><td>bag(numeric) &rarr; numeric</td><td>minimum of all values</td></tr>
<tr><td>avg</td><td>bag(numeric) &rarr; float/double</td><td>average of all values</td></tr>
<tr><td>some</td><td>bag(boolean) &rarr; boolean</td><td>true if any value in the bag is true</td></tr>
<tr><td>all</td><td>bag(boolean) &rarr; boolean</td><td>true if all the values in the bag are true</td></tr>
<tr><td>exists</td><td>bag(&alpha;) &rarr; boolean</td><td>true if the bag is not empty</td></tr>
<tr><td>member</td><td>(&alpha;,bag(&alpha;)) &rarr; boolean</td><td>true if the element is a member of the bag</td></tr>

<tr><td>union</td><td>(bag(&alpha;),bag(&alpha;)) &rarr; bag(&alpha;)</td><td>bag union (infix)</td></tr>
<tr><td>intersect</td><td>(bag(&alpha;),bag(&alpha;)) &rarr; bag(&alpha;)</td><td>bag intersection (infix)</td></tr>
<tr><td>except</td><td>(bag(&alpha;),bag(&alpha;)) &rarr; bag(&alpha;)</td><td>bag difference (infix)</td></tr>

<tr><td>text</td><td>XML &rarr; string</td><td>the text content of an XML node</td></tr>
<tr><td>text</td><td>list(XML) &rarr; string</td><td>the concatenated text content of an XML sequence</td></tr>
<tr><td>tag</td><td>XML &rarr; string</td><td>the tagname of an XML element node</td></tr>

<tr><td>random</td><td>int &rarr; int</td><td>return a random number between 0 and the argument - 1 (an impure function))</td></tr>
<tr><td>inv</td><td>&alpha; &rarr; Inv(&alpha;)</td><td>invert the total order &le; of the value</td></tr>

</tr>

</tbody>
</table>
<hr>
<address>Last modified: 04/19/12 by <a href="http://lambda.uta.edu/">Leonidas Fegaras</a></address>
</body>
</html>
